{extend name="layout/main" /}

{block name="header"}

{/block}

{block name="content"}
<!--<link rel="stylesheet" href="http://cdn.staticfile.org/webuploader/0.1.5/webuploader.css">-->
<!--<script type="text/javascript" src='http://cdn.staticfile.org/webuploader/0.1.5/webuploader.min.js'></script>-->
<style type="text/css">
    /*body{*/
    /*overflow-x:hidden;*/
    /*overflow-y: auto;*/
    /*width:100%;*/
    /*}*/
    /*.table{*/
    /*display: block;*/
    /*overflow-y: hidden;*/
    /*overflow-x: auto;*/
    /*}*/
    /*.form-control{*/
    /*width: auto;*/
    /*}*/

</style>


<section class="panel">
    <header class="panel-heading">
        <h4>房主等级配置</h4>
    </header>
    <div class="panel-body" style="padding-bottom: 50px">
        <table class="table table-bordered table-striped no-margin">
            <thead>
            <tr>
                <th class="text-center">序号</th>
                <th class="text-center">等级名称</th>
                <th class="text-center">直推人数</th>
                <th class="text-center">团队总人数</th>
                <th class="text-center">个人业绩</th>
                <th class="text-center">团队业绩</th>
                <th class="text-center">团长等级和人数</th>
                <!--<th class="text-center">需要人数(团长等级)</th>-->
                <!--<th class="text-center">佣金提成</th>-->
                <th class="text-center">分红比例</th>
                <th class="text-center">操作</th>
            </tr>
            </thead>
            <tbody>
            {foreach $list as $key=>$config}
            <tr>
                <td class="text-center" style="vertical-align: middle; ">{$key+1}</td>
                <td class="text-center" style="vertical-align: middle; ">
                    <!--{$config->name}-->
                    <input type="text" id="_name_{$config['id']}" style="text-align: center" class="form-control" value="{$config['name']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_direct_{$config['id']}" style="text-align: center" class="form-control" value="{$config['direct']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_team_{$config['id']}" style="text-align: center" class="form-control" value="{$config['team']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_selfperformance_{$config['id']}" style="text-align: center" class="form-control" value="{$config['selfperformance']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_teamperformance_{$config['id']}" style="text-align: center" class="form-control"
                           value="{$config['teamperformance']}">
                </td>

                <td class="text-center" style="vertical-align: middle; ">
                    <!---->
                    <select name="teamlevelid" id="_teamlevelid_{$config['id']}">
                        <option value="0">无</option>
                        {foreach $team as $k=>$v}
                        <option value="{$v.id}" {if $v.id == $config['teamlevelid']}selected{/if}>{$v.name}</option>
                        {/foreach}
                    </select>
                    <input type="text" id="_teamnumber_{$config['id']}" style="text-align: center" class="form-control" value="{$config['teamnumber']}">
                </td>

                <!--<td class="text-center" style="vertical-align: middle; ">-->
                    <!--<input type="text" id="_teamnumber_{$config['id']}" style="text-align: center" class="form-control" value="{$config['teamnumber']}">-->
                <!--</td>-->
                <!--<td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_percentage_{$config['id']}" style="text-align: center" class="form-control" value="{$config['percentage']}">
                </td>-->

                <td class="text-center" style="vertical-align: middle; ">
                    <input type="text" id="_peers_{$config['id']}" style="text-align: center" class="form-control" value="{$config['peers']}">
                </td>
                <td class="text-center" style="vertical-align: middle; ">
                    <a onclick="updateConfigCopy(this)"
                       data-level="{$config['name']}"
                       id-data="{$config['id']}" class="btn btn-xs btn-primary">确认修改</a>
                </td>

            </tr>
            <!-- {/if} -->
            {/foreach}
            </tbody>
        </table>
        提示：要满足以上的条件才能升级，不需要的条件不需要填，填0即可
    </div>
</section>


{/block}

{block name="footer"}

<script>

    function updateConfigCopy(e) {
        var id = $(e).attr('id-data');
        var name = $('#_name_' +id).val();
        var direct = $('#_direct_' +id).val();
        var team = $('#_team_' +id).val();
        var selfperformance = $('#_selfperformance_' +id).val();
        var teamperformance = $('#_teamperformance_' +id).val();
        var percentage = $('#_percentage_' +id).val();
       
        var teamlevelid = $('#_teamlevelid_' +id).val();
        var teamnumber = $('#_teamnumber_' +id).val();
        var peers = $('#_peers_' +id).val();

        console.log({
            id: id,
            team: team,
            selfperformance:selfperformance,
            teamperformance:teamperformance,
            percentage:percentage,
            
        });
        $.post("{:url('housesave')}", {
            id: id,
            name:name,
            direct:direct,
            team: team,
            selfperformance:selfperformance,
            teamperformance:teamperformance,
            percentage:percentage,
            teamlevelid:teamlevelid,
            teamnumber:teamnumber,
            peers:peers,
        }, function (data) {
            if (data.code == 1) {
                main.waringAlert(data.message);
            } else {
                main.waringAlert(data.message);
                window.location.reload();
            }
        }, 'json')
    }




</script>


</script>
{/block}
